/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.dbdir;

import java.io.Console;
import java.util.ArrayList;
import org.dbdir.core.AccessData;
import org.dbdir.core.Backup;
import org.dbdir.core.datastore.db.SQLManager;
import org.dbdir.core.helper.ACL;
import org.dbdir.core.helper.Admin;
import org.dbdir.core.helper.Database;
import org.dbdir.core.helper.User;

/**
 *
 * @author thotheolh
 */
public class ServerConsole extends Thread {

    private Server server = null;
    private Console input = null;
    private SQLManager sql = null;
    private AccessData access = null;

    // Values
    private String val_Username = null;
    private String val_Password = null;
    private String val_DBPath = null;
    private String val_Alias = null;
    private String val_DBUser = null;
    private String val_DBPass = null;
    private String val_OldAdmin = null;
    private String val_NewAdmin = null;
    private boolean val_showDbPath = false;
    private boolean val_showDbUsername = false;
    private boolean val_showDbPassword = false;
    private boolean val_showDateTimeReg = false;
    private boolean val_editDbPath = false;
    private boolean val_editDbUsername = false;
    private boolean val_editDbPassword = false;
    // Keys
    private String key_Username = "username";
    private String key_Password = "password";
    private String key_DBPath = "dbpath";
    private String key_Alias = "dbalias";
    private String key_DBUser = "dbusr";
    private String key_DBPass = "dbpwd";
    private String key_showDbPath = "showdbpath";
    private String key_showDbUsername = "showdbusr";
    private String key_showDbPassword = "showdbpwd";
    private String key_showDateTimeReg = "showdtreg";
    private String key_editDbPath = "editdbpath";
    private String key_editDbUsername = "editdbusr";
    private String key_editDbPassword = "editdbpwd";
    private String key_OldAdmin = "oldadmin";
    private String key_NewAdmin = "newadmin";

    public ServerConsole(SQLManager sql, Server inserver) {
        this.server = inserver;
        input = server.getInput();
        this.setSql(sql);
        access = new AccessData(sql);
    // output("ServerConsole"); //diagnostic
    //output("SQL: ");
    // output("ServerConsole: "+server.toString()+",SQL: "+sql.conn.toString());
    }

    @Override
    public void run() {
        acceptCommand();
    }

    private void acceptCommand() {
        do {
            try {
                String command = input.readLine(">:");
                processServerCommand(command);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        } while (true);
    }

    private String convertBoolToStr(boolean bool) {
        if (bool == true) {
            return "true";
        } else {
            return "false";
        }
    }

    private boolean convertToBool(String string) {
        if (string.equalsIgnoreCase("true")) {
            return true;
        } else {
            return false;
        }
    }

    private void handleMainMenuOption(int option) {
        if (option == 1) {
        } else if (option == 2) {
        } else if (option == 3) {
        } else if (option == 4) {
        } else if (option == 5) {
        } else if (option == 6) {
        } else if (option == 7) {
        } else if (option == 8) {
        } else if (option == 9) {
        } else {
        }
    }

    private void processServerCommand(String command) {
        // output("Proccessing command..."); diagnostic
        String[] args = command.split("\\s+");
        // output("split...."); diagnostic
        if (args[0].equalsIgnoreCase("exit")) {
            doExitServer();
        }
        if (args[0].equalsIgnoreCase("bye")) {
            doExitServer();
        }
        if (args[0].equalsIgnoreCase("quit")) {
            doExitServer();
        }
        if (args[0].equalsIgnoreCase("help")) {
            if (args.length >= 2) {
                this.doSpecificHelp(args[1]);
            } else {
                this.doHelp();
            }
        }
        if (args[0].equalsIgnoreCase("?")) {
            if (args.length >= 2) {
                this.doSpecificHelp(args[1]);
            } else {
                this.doHelp();
            }
        }
        if (args[0].equalsIgnoreCase("about")) {
            doAbout();
        }
        if (args[0].equalsIgnoreCase("adduser")) {
            // output("Not Yet Implemented\n\r");
            String[] value1 = args[1].split("=");
            String[] value2 = args[2].split("=");
            if (value1[0].equals(this.key_Username)) {
                this.val_Username = value1[1];
            } else if (value1[0].equals(this.key_Password)) {
                this.val_Password = value1[1];
            }
            if (value2[0].equals(this.key_Username)) {
                this.val_Username = value2[1];
            } else if (value2[0].equals(this.key_Password)) {
                this.val_Password = value2[1];
            }
            if (this.val_Username == null || this.val_Password == null) {
                output("(!) Wrong syntax or the Password and Username is not defined. Type 'help adduser' for help.\n\r");
            } // output(value1[0]+","+value1[1]+","+value2[0]+","+value2[1]+"\n\r"); // diagnostic
            else {
                boolean ok = access.doRegisterUser(val_Username, val_Password);
                if (ok == true) {
                    output("User: " + this.val_Username + ", have SUCCESSFULLY been REGISTERED.\n\r");
                } else {
                    output("User: " + this.val_Username + ", have FAILED to be REGISTERED.\n\r");
                }
            }
            resetAllVals();
        }
        if (args[0].equalsIgnoreCase("moduser")) {
            output("Not Yet Implemented\n\r");
        }
        if (args[0].equalsIgnoreCase("deluser")) {
            // output("Not Yet Implemented\n\r");
            String[] value1 = args[1].split("=");
            if (value1[0].equals(this.key_Username)) {
                this.val_Username = value1[1];
            }
            if (this.val_Username == null) {
                output("(!) Wrong syntax. Type 'help deluser' for help.\n\r");
            } // output(value1[0]+","+value1[1]+","+value2[0]+","+value2[1]+"\n\r"); // diagnostic
            else {
                boolean ok = getSql().deleteUser(this.val_Username);
                if (ok == true) {
                    output("User: " + this.val_Username + ", have SUCCESSFULLY been DELETED.\n\r");
                } else {
                    output("User: " + this.val_Username + ", have FAILED to be DELETED.\n\r");
                }
            }
            resetAllVals();
        }
        if (args[0].equalsIgnoreCase("showuser")) {
            // output("Not Yet Implemented\n\r");
            //get user by name
            User user = getSql().getUserByName(args[1]);
            if (user != null) {
                output("User: " + user.getUsername() + "\n\r" + "Password: " + user.getPassword() + "\n\r");

            } else {
                output("User: " + args[1] + ", DOES NOT exist.\n\r");
            }

            resetAllVals();
        }
        if (args[0].equalsIgnoreCase("listuser")) {
            // output("Not Yet Implemented\n\r");
            int i;
            output("List of User(s)\n\r");
            output("===============\n\r");
            ArrayList aList = getSql().listUsername();
            for (i = 0; i < aList.size(); i++) {
                output(aList.get(i) + "\n\r");
            }
            output("Total Number of Users: " + i + "\n");
        }
        if (args[0].equalsIgnoreCase("adddb")) {
            // output("Not Yet Implemented\n\r");
            String[] value1 = args[1].split("=");
            String[] value2 = args[2].split("=");
            String[] value3 = args[3].split("=");
            String[] value4 = args[4].split("=");
            if (value1[0].equals(this.key_Alias)) {
                this.val_Alias = value1[1];
            } else if (value1[0].equals(this.key_DBUser)) {
                this.val_DBUser = value1[1];
            } else if (value1[0].equals(this.key_DBPass)) {
                this.val_DBPass = value1[1];
            } else if (value1[0].equals(this.key_DBPath)) {
                this.val_DBPath = value1[1];
            }
            if (value2[0].equals(this.key_Alias)) {
                this.val_Alias = value2[1];
            } else if (value2[0].equals(this.key_DBUser)) {
                this.val_DBUser = value2[1];
            } else if (value2[0].equals(this.key_DBPass)) {
                this.val_DBPass = value2[1];
            } else if (value2[0].equals(this.key_DBPath)) {
                this.val_DBPath = value2[1];
            }
            if (value3[0].equals(this.key_Alias)) {
                this.val_Alias = value3[1];
            } else if (value3[0].equals(this.key_DBUser)) {
                this.val_DBUser = value3[1];
            } else if (value3[0].equals(this.key_DBPass)) {
                this.val_DBPass = value3[1];
            } else if (value3[0].equals(this.key_DBPath)) {
                this.val_DBPath = value3[1];
            }
            if (value4[0].equals(this.key_Alias)) {
                this.val_Alias = value4[1];
            } else if (value4[0].equals(this.key_DBUser)) {
                this.val_DBUser = value4[1];
            } else if (value4[0].equals(this.key_DBPass)) {
                this.val_DBPass = value4[1];
            } else if (value4[0].equals(this.key_DBPath)) {
                this.val_DBPath = value4[1];
            }
            output(this.val_Alias + "," + this.val_DBUser + "," + this.val_DBPass + "," + this.val_DBPath);
            if (this.val_DBUser == null || this.val_DBPass == null || this.val_Alias == null || this.val_DBPath == null) {
                output("(!) Wrong syntax. Type 'help adddb' for help.\n\r");
            // output(value1[0]+","+value1[1]+","+value2[0]+","+value2[1]+","+value3[0]+","+value3[1]+","+value4[0]+","+value4[1]+"\n\r"); // diagnostic
            } else {
                Database db = new Database();
                db.setDbUsername(val_DBUser);
                db.setDbPassword(val_DBPass);
                db.setDbAlias(val_Alias);
                db.setDbPath(val_DBPath);
                boolean ok = getSql().addDatabaseInfo(db);
                if (ok == true) {
                    output("DB Alias: " + this.val_DBUser + ", have SUCCESSFULLY been REGISTERED.\n\r");
                } else {
                    output("User: " + this.val_DBUser + ", have FAILED to be REGISTERED.\n\r");
                }
            }
            resetAllVals();
        }
        if (args[0].equalsIgnoreCase("moddb")) {
            // output("Not Yet Implemented\n\r");
            String[] value1 = args[1].split("=");
            String[] value2 = args[2].split("=");
            String[] value3 = args[3].split("=");
            String[] value4 = args[4].split("=");
            if (value1[0].equals(this.key_Alias)) {
                this.val_Alias = value1[1];
            } else if (value1[0].equals(this.key_DBUser)) {
                this.val_DBUser = value1[1];
            } else if (value1[0].equals(this.key_DBPass)) {
                this.val_DBPass = value1[1];
            } else if (value1[0].equals(this.key_DBPath)) {
                this.val_DBPath = value1[1];
            }
            if (value2[0].equals(this.key_Alias)) {
                this.val_Alias = value2[1];
            } else if (value2[0].equals(this.key_DBUser)) {
                this.val_DBUser = value2[1];
            } else if (value2[0].equals(this.key_DBPass)) {
                this.val_DBPass = value2[1];
            } else if (value2[0].equals(this.key_DBPath)) {
                this.val_DBPath = value2[1];
            }
            if (value3[0].equals(this.key_Alias)) {
                this.val_Alias = value3[1];
            } else if (value3[0].equals(this.key_DBUser)) {
                this.val_DBUser = value3[1];
            } else if (value3[0].equals(this.key_DBPass)) {
                this.val_DBPass = value3[1];
            } else if (value3[0].equals(this.key_DBPath)) {
                this.val_DBPath = value3[1];
            }
            if (value4[0].equals(this.key_Alias)) {
                this.val_Alias = value4[1];
            } else if (value4[0].equals(this.key_DBUser)) {
                this.val_DBUser = value4[1];
            } else if (value4[0].equals(this.key_DBPass)) {
                this.val_DBPass = value4[1];
            } else if (value4[0].equals(this.key_DBPath)) {
                this.val_DBPath = value4[1];
            }
            // output(this.val_Alias + "," + this.val_DBUser + "," + this.val_DBPass + "," + this.val_DBPath);
            if (this.val_DBUser == null || this.val_DBPass == null || this.val_Alias == null || this.val_DBPath == null) {
                output("(!) Wrong syntax. Type 'help moddb' for help.\n\r");
                output(value1[0] + "," + value1[1] + "," + value2[0] + "," + value2[1] + "," + value3[0] + "," + value3[1] + "," + value4[0] + "," + value4[1] + "\n\r"); // diagnostic
            } else {
                Database db = new Database();
                db.setDbUsername(this.val_DBUser);
                db.setDbPassword(this.val_DBPass);
                db.setDbPath(this.val_DBPath);
                db.setDbAlias(val_Alias);
                boolean ok = getSql().updateDatabaseInfo(db);
                if (ok == true) {
                    output("DB Alias: " + this.val_Alias + ", have SUCCESSFULLY been UPDATED.\n\r");
                } else {
                    output("User: " + this.val_Alias + ", have FAILED to be UPDATED.\n\r");
                }
            }
            resetAllVals();
        }
        if (args[0].equalsIgnoreCase("deldb")) {
            // output("Not Yet Implemented\n\r");
            String[] value1 = args[1].split("=");
            if (value1[0].equals(this.key_Alias)) {
                this.val_Alias = value1[1];
            }
            if (this.val_Alias == null) {
                output("(!) Wrong syntax. Type 'help deldb' for help.\n\r");
            } // output(value1[0]+","+value1[1]+","+value2[0]+","+value2[1]+"\n\r"); // diagnostic
            else {
                boolean ok = getSql().deleteDatabaseInfo(val_Alias);
                if (ok == true) {
                    output("DB Profile: " + this.val_Alias + ", have SUCCESSFULLY been DELETED.\n\r");
                } else {
                    output("DB Profile: " + this.val_Alias + ", have FAILED to be DELETED.\n\r");
                }
            }
            resetAllVals();
        }
        if (args[0].equalsIgnoreCase("showdb")) {
            // output("Not Yet Implemented\n\r");
            Database data = getSql().getDatabaseInfoByName(args[1]);
            if (data != null) {
                output("DB Alias: " + data.getDbAlias() + "\n\r" + "DB Username: " + data.getDbUsername() + "\n\r" + "DB Password: " + data.getDbPassword() + "\n\r" + "DB Path: " + data.getDbPath() + "\n\r");
            } else {
                output("DB Profile: " + args[1] + ", DOES NOT exist.\n\r");
            }

            resetAllVals();
        }
        if (args[0].equalsIgnoreCase("listdb")) {
            // output("Not Yet Implemented\n\r");
            int i;
            output("List of DB Alias\n\r");
            output("=====================\n\r");
            ArrayList aList = getSql().listDBAlias();
            for (i = 0; i < aList.size(); i++) {
                output(aList.get(i) + "\n\r");
            }
            output("Total Number of DB Profile: " + i + "\n");
        }
        if (args[0].equalsIgnoreCase("addacl")) {
            // output("Not Yet Implemented\n\r");
            String[] value1 = args[1].split("=");
            String[] value2 = args[2].split("=");
            String[] value3 = args[3].split("=");
            String[] value4 = args[4].split("=");
            String[] value5 = args[5].split("=");
            String[] value6 = args[6].split("=");
            String[] value7 = args[7].split("=");
            String[] value8 = args[8].split("=");
            String[] value9 = args[9].split("=");
            if (value1[0].equals(this.key_Username)) {
                this.val_Username = value1[1];
            } else if (value1[0].equals(this.key_Alias)) {
                this.val_Alias = value1[1];
            } else if (value1[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value1[1]);
            } else if (value1[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value1[1]);
            } else if (value1[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value1[1]);
            } else if (value1[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value1[1]);
            } else if (value1[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value1[1]);
            } else if (value1[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value1[1]);
            } else if (value1[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value1[1]);
            }
            if (value2[0].equals(this.key_Username)) {
                this.val_Username = value2[1];
            } else if (value2[0].equals(this.key_Alias)) {
                this.val_Alias = value2[1];
            } else if (value2[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value2[1]);
            } else if (value2[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value2[1]);
            } else if (value2[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value2[1]);
            } else if (value2[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value2[1]);
            } else if (value2[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value2[1]);
            } else if (value2[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value2[1]);
            } else if (value2[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value2[1]);
            }
            if (value3[0].equals(this.key_Username)) {
                this.val_Username = value3[1];
            } else if (value3[0].equals(this.key_Alias)) {
                this.val_Alias = value3[1];
            } else if (value3[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value3[1]);
            } else if (value3[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value3[1]);
            } else if (value3[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value3[1]);
            } else if (value3[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value3[1]);
            } else if (value3[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value3[1]);
            } else if (value3[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value3[1]);
            } else if (value3[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value3[1]);
            }
            if (value4[0].equals(this.key_Username)) {
                this.val_Username = value4[1];
            } else if (value4[0].equals(this.key_Alias)) {
                this.val_Alias = value4[1];
            } else if (value4[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value4[1]);
            } else if (value4[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value4[1]);
            } else if (value4[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value4[1]);
            } else if (value4[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value4[1]);
            } else if (value4[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value4[1]);
            } else if (value4[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value4[1]);
            } else if (value4[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value4[1]);
            }
            if (value5[0].equals(this.key_Username)) {
                this.val_Username = value5[1];
            } else if (value5[0].equals(this.key_Alias)) {
                this.val_Alias = value5[1];
            } else if (value5[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value5[1]);
            } else if (value5[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value5[1]);
            } else if (value5[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value5[1]);
            } else if (value5[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value5[1]);
            } else if (value5[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value5[1]);
            } else if (value5[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value5[1]);
            } else if (value5[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value5[1]);
            }
            if (value6[0].equals(this.key_Username)) {
                this.val_Username = value6[1];
            } else if (value6[0].equals(this.key_Alias)) {
                this.val_Alias = value6[1];
            } else if (value6[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value6[1]);
            } else if (value6[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value6[1]);
            } else if (value6[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value6[1]);
            } else if (value6[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value6[1]);
            } else if (value6[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value6[1]);
            } else if (value6[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value6[1]);
            } else if (value6[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value6[1]);
            }
            if (value7[0].equals(this.key_Username)) {
                this.val_Username = value7[1];
            } else if (value7[0].equals(this.key_Alias)) {
                this.val_Alias = value7[1];
            } else if (value7[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value7[1]);
            } else if (value7[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value7[1]);
            } else if (value7[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value7[1]);
            } else if (value7[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value7[1]);
            } else if (value7[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value7[1]);
            } else if (value7[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value7[1]);
            } else if (value7[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value7[1]);
            }
            if (value8[0].equals(this.key_Username)) {
                this.val_Username = value8[1];
            } else if (value8[0].equals(this.key_Alias)) {
                this.val_Alias = value8[1];
            } else if (value8[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value8[1]);
            } else if (value8[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value8[1]);
            } else if (value8[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value8[1]);
            } else if (value8[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value8[1]);
            } else if (value8[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value8[1]);
            } else if (value8[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value8[1]);
            } else if (value8[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value8[1]);
            }
            if (value9[0].equals(this.key_Username)) {
                this.val_Username = value9[1];
            } else if (value9[0].equals(this.key_Alias)) {
                this.val_Alias = value9[1];
            } else if (value9[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value9[1]);
            } else if (value9[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value9[1]);
            } else if (value9[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value9[1]);
            } else if (value9[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value9[1]);
            } else if (value9[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value9[1]);
            } else if (value9[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value9[1]);
            } else if (value9[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value9[1]);
            }

            // output(this.val_Alias + "," + this.val_DBUser + "," + this.val_DBPass + "," + this.val_DBPath);
            if (this.val_Username == null || this.val_Alias == null) {
                output("(!) Wrong syntax. Type 'help addacl' for help.\n\r");
            // output(value1[0]+","+value1[1]+","+value2[0]+","+value2[1]+","+value3[0]+","+value3[1]+","+value4[0]+","+value4[1]+"\n\r"); // diagnostic
            } else {
                ACL acl = new ACL(this.val_Username, this.val_Alias, this.val_showDbPath, this.val_showDbUsername, this.val_showDbPassword, this.val_showDateTimeReg, this.val_editDbPath, this.val_editDbUsername, this.val_editDbPassword);
                boolean ok = getSql().addACL(acl);
                if (ok == true) {
                    output("ACL have SUCCESSFULLY been ADDED.\n\r");
                } else {
                    output("ACL have FAILED to be ADDED.\n\r");
                }
            }
            resetAllVals();

        }
        if (args[0].equalsIgnoreCase("modacl")) {
            // output("Not Yet Implemented\n\r");
            String[] value1 = args[1].split("=");
            String[] value2 = args[2].split("=");
            String[] value3 = args[3].split("=");
            String[] value4 = args[4].split("=");
            String[] value5 = args[5].split("=");
            String[] value6 = args[6].split("=");
            String[] value7 = args[7].split("=");
            String[] value8 = args[8].split("=");
            String[] value9 = args[9].split("=");
            if (value1[0].equals(this.key_Username)) {
                this.val_Username = value1[1];
            } else if (value1[0].equals(this.key_Alias)) {
                this.val_Alias = value1[1];
            } else if (value1[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value1[1]);
            } else if (value1[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value1[1]);
            } else if (value1[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value1[1]);
            } else if (value1[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value1[1]);
            } else if (value1[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value1[1]);
            } else if (value1[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value1[1]);
            } else if (value1[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value1[1]);
            }
            if (value2[0].equals(this.key_Username)) {
                this.val_Username = value2[1];
            } else if (value2[0].equals(this.key_Alias)) {
                this.val_Alias = value2[1];
            } else if (value2[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value2[1]);
            } else if (value2[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value2[1]);
            } else if (value2[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value2[1]);
            } else if (value2[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value2[1]);
            } else if (value2[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value2[1]);
            } else if (value2[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value2[1]);
            } else if (value2[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value2[1]);
            }
            if (value3[0].equals(this.key_Username)) {
                this.val_Username = value3[1];
            } else if (value3[0].equals(this.key_Alias)) {
                this.val_Alias = value3[1];
            } else if (value3[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value3[1]);
            } else if (value3[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value3[1]);
            } else if (value3[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value3[1]);
            } else if (value3[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value3[1]);
            } else if (value3[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value3[1]);
            } else if (value3[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value3[1]);
            } else if (value3[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value3[1]);
            }
            if (value4[0].equals(this.key_Username)) {
                this.val_Username = value4[1];
            } else if (value4[0].equals(this.key_Alias)) {
                this.val_Alias = value4[1];
            } else if (value4[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value4[1]);
            } else if (value4[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value4[1]);
            } else if (value4[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value4[1]);
            } else if (value4[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value4[1]);
            } else if (value4[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value4[1]);
            } else if (value4[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value4[1]);
            } else if (value4[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value4[1]);
            }
            if (value5[0].equals(this.key_Username)) {
                this.val_Username = value5[1];
            } else if (value5[0].equals(this.key_Alias)) {
                this.val_Alias = value5[1];
            } else if (value5[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value5[1]);
            } else if (value5[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value5[1]);
            } else if (value5[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value5[1]);
            } else if (value5[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value5[1]);
            } else if (value5[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value5[1]);
            } else if (value5[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value5[1]);
            } else if (value5[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value5[1]);
            }
            if (value6[0].equals(this.key_Username)) {
                this.val_Username = value6[1];
            } else if (value6[0].equals(this.key_Alias)) {
                this.val_Alias = value6[1];
            } else if (value6[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value6[1]);
            } else if (value6[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value6[1]);
            } else if (value6[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value6[1]);
            } else if (value6[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value6[1]);
            } else if (value6[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value6[1]);
            } else if (value6[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value6[1]);
            } else if (value6[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value6[1]);
            }
            if (value7[0].equals(this.key_Username)) {
                this.val_Username = value7[1];
            } else if (value7[0].equals(this.key_Alias)) {
                this.val_Alias = value7[1];
            } else if (value7[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value7[1]);
            } else if (value7[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value7[1]);
            } else if (value7[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value7[1]);
            } else if (value7[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value7[1]);
            } else if (value7[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value7[1]);
            } else if (value7[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value7[1]);
            } else if (value7[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value7[1]);
            }
            if (value8[0].equals(this.key_Username)) {
                this.val_Username = value8[1];
            } else if (value8[0].equals(this.key_Alias)) {
                this.val_Alias = value8[1];
            } else if (value8[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value8[1]);
            } else if (value8[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value8[1]);
            } else if (value8[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value8[1]);
            } else if (value8[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value8[1]);
            } else if (value8[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value8[1]);
            } else if (value8[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value8[1]);
            } else if (value8[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value8[1]);
            }
            if (value9[0].equals(this.key_Username)) {
                this.val_Username = value9[1];
            } else if (value9[0].equals(this.key_Alias)) {
                this.val_Alias = value9[1];
            } else if (value9[0].equals(this.key_showDbPath)) {
                this.val_showDbPath = convertToBool(value9[1]);
            } else if (value9[0].equals(this.key_showDbUsername)) {
                this.val_showDbUsername = convertToBool(value9[1]);
            } else if (value9[0].equals(this.key_showDbPassword)) {
                this.val_showDbPassword = convertToBool(value9[1]);
            } else if (value9[0].equals(this.key_showDateTimeReg)) {
                this.val_showDateTimeReg = convertToBool(value9[1]);
            } else if (value9[0].equals(this.key_editDbPath)) {
                this.val_editDbPath = convertToBool(value9[1]);
            } else if (value9[0].equals(this.key_editDbUsername)) {
                this.val_editDbUsername = convertToBool(value9[1]);
            } else if (value9[0].equals(this.key_editDbPassword)) {
                this.val_editDbPassword = convertToBool(value9[1]);
            }

            // output(this.val_Alias + "," + this.val_DBUser + "," + this.val_DBPass + "," + this.val_DBPath);
            if (this.val_Username == null || this.val_Alias == null) {
                output("(!) Wrong syntax. Type 'help modacl' for help.\n\r");
            // output(value1[0]+","+value1[1]+","+value2[0]+","+value2[1]+","+value3[0]+","+value3[1]+","+value4[0]+","+value4[1]+"\n\r"); // diagnostic
            } else {
//                if (getSql().checkAdminByUserDB(val_Username, val_Alias)) {
//                    ACL acl = getSql().getACL(val_Username, val_Alias);
//                    if (server.getFunct().isAdminACLOk(acl) == false) {
//                        boolean ok = getSql().updateACL(server.getFunct().correctAdminACL(acl));
//                        if (ok == true) {
//                            output("ACL for Admins cannot be modified.\n\r");
//                        }else{
//
//                        }
//                    }
//                } else {
                    ACL acl = new ACL(this.val_Username, this.val_Alias, this.val_showDbPath, this.val_showDbUsername, this.val_showDbPassword, this.val_showDateTimeReg, this.val_editDbPath, this.val_editDbUsername, this.val_editDbPassword);
                    boolean ok = getSql().updateACL(acl);
                    if (ok == true) {
                        output("ACL have SUCCESSFULLY been UPDATED.\n\r");
                    } else {
                        output("ACL have FAILED to be UPDATED.\n\r");
                    }
                //}
            }
            resetAllVals();
        }
        if (args[0].equalsIgnoreCase("delacl")) {
            // output("Not Yet Implemented\n\r");
            String[] value1 = args[1].split("=");
            String[] value2 = args[2].split("=");
            if (value1[0].equals(this.key_Username)) {
                this.val_Username = value1[1];
            } else if (value1[0].equals(this.key_Alias)) {
                this.val_Alias = value1[1];
            }
            if (value2[0].equals(this.key_Username)) {
                this.val_Username = value2[1];
            } else if (value2[0].equals(this.key_Alias)) {
                this.val_Alias = value2[1];
            }
            if (this.val_Alias == null || this.val_Username == null) {
                output("(!) Wrong syntax. Type 'help delacl' for help.\n\r");
            } // output(value1[0]+","+value1[1]+","+value2[0]+","+value2[1]+"\n\r"); // diagnostic
            else {
                boolean ok = getSql().deleteACL(val_Username, val_Alias);
                if (ok == true) {
                    output("ACL for " + this.val_Username + " in DB Profile: " + this.val_Alias + ", have SUCCESSFULLY been DELETED.\n\r");
                } else {
                    output("ACL for " + this.val_Username + " in DB Profile: " + this.val_Alias + ", have FAILED to be DELETED.\n\r");
                }
            }
            resetAllVals();
        }
        if (args[0].equalsIgnoreCase("showacl")) {
            // output("Not Yet Implemented\n\r");
            String[] value1 = args[1].split("=");
            String[] value2 = args[2].split("=");
            if (value1[0].equals(this.key_Username)) {
                this.val_Username = value1[1];
            } else if (value1[0].equals(this.key_Alias)) {
                this.val_Alias = value1[1];
            }
            if (value2[0].equals(this.key_Username)) {
                this.val_Username = value2[1];
            } else if (value2[0].equals(this.key_Alias)) {
                this.val_Alias = value2[1];
            }
            if (this.val_Alias == null || this.val_Username == null) {
                output("(!) Wrong syntax. Type 'help delacl' for help.\n\r");
            } // output(value1[0]+","+value1[1]+","+value2[0]+","+value2[1]+"\n\r"); // diagnostic
            else {
                ACL acl = getSql().getACL(val_Username, val_Alias);
                if (acl != null) {
                    output("Username: " + acl.getUsername() + "\n\r" + "DB Alias: " + acl.getDbAlias() + "\n\r" + "Show\n\r" +
                            "====\n\r" + "DB Path: " + convertBoolToStr(acl.isShowDbPath()) + "\n\r" + "DB Username: " +
                            convertBoolToStr(acl.isShowDbUsername()) + "\n\r" + "DB Password: " + convertBoolToStr(acl.isShowDbPassword()) +
                            "\n\r" + "DateTime Reg: " + convertBoolToStr(acl.isShowDateTimeReg()) + "\n\r" + "Edit\n\r" + "====\n\r" +
                            "DB Path: " + convertBoolToStr(acl.isEditDbPath()) + "\n\r" + "DB Username: " +
                            convertBoolToStr(acl.isEditDbUsername()) + "\n\r" + "DB Password: " + convertBoolToStr(acl.isEditDbPassword()) +
                            "\n\r");
                } else {
                    output("ACL for " + this.val_Username + "in DB Profile: " + this.val_Alias + ", DOES NOT EXIST.\n\r");
                }
            }
            resetAllVals();
        }
        if (args[0].equalsIgnoreCase("listacl")) {
            // output("Not Yet Implemented\n\r");
            int i;
            output("List of ACL\n\r");
            output("=====================\n\r");
            ArrayList aList = getSql().listACL();
            ACL acl;
            for (i = 0; i < aList.size(); i++) {
                acl = (ACL) aList.get(i);
                output("Username: " + acl.getUsername() + ", DB Alias: " + acl.getDbAlias() + "\n\r");
            }
            output("Total Number of ACL: " + i + "\n");
        }
        if (args[0].equalsIgnoreCase("mkdbadmin")) {
            // output("Not Yet Implemented\n\r");
            String[] value1 = args[1].split("=");
            String[] value2 = args[2].split("=");
            if (value1[0].equals(this.key_Username)) {
                this.val_Username = value1[1];
            } else if (value1[0].equals(this.key_Alias)) {
                this.val_Alias = value1[1];
            }
            if (value2[0].equals(this.key_Username)) {
                this.val_Username = value2[1];
            } else if (value2[0].equals(this.key_Alias)) {
                this.val_Alias = value2[1];
            }
            if (this.val_Alias == null || this.val_Username == null) {
                output("(!) Wrong syntax. Type 'help mkdbadmin' for help.\n\r");
            } // output(value1[0]+","+value1[1]+","+value2[0]+","+value2[1]+"\n\r"); // diagnostic
            else {
                boolean ok = getSql().addAdmin(new Admin(val_Username, val_Alias));
                if (ok == true) {
                    output("User: " + this.val_Username + ", admin for " + this.val_Alias + ", have SUCCESSFULLY been MADE.\n\r");
                } else {
                    output("User: " + this.val_Username + ", admin for " + this.val_Alias + ", have FAILED to be MADE.\n\r");
                }
            }
            resetAllVals();
        }
        if (args[0].equalsIgnoreCase("chdbadmin")) {
            // output("Not Yet Implemented\n\r");
            String[] value1 = args[1].split("=");
            String[] value2 = args[2].split("=");
            String[] value3 = args[3].split("=");
            if (value1[0].equals(this.key_OldAdmin)) {
                this.val_OldAdmin = value1[1];
            } else if (value1[0].equals(this.key_NewAdmin)) {
                this.val_NewAdmin = value1[1];
            } else if (value1[0].equals(this.key_Alias)) {
                this.val_Alias = value1[1];
            }
            if (value2[0].equals(this.key_OldAdmin)) {
                this.val_OldAdmin = value2[1];
            } else if (value2[0].equals(this.key_NewAdmin)) {
                this.val_NewAdmin = value2[1];
            } else if (value2[0].equals(this.key_Alias)) {
                this.val_Alias = value2[1];
            }
            if (value3[0].equals(this.key_OldAdmin)) {
                this.val_OldAdmin = value3[1];
            } else if (value3[0].equals(this.key_NewAdmin)) {
                this.val_NewAdmin = value3[1];
            } else if (value3[0].equals(this.key_Alias)) {
                this.val_Alias = value3[1];
            }
            if (this.val_Alias == null || this.val_OldAdmin == null || this.val_NewAdmin == null) {
                output("(!) Wrong syntax. Type 'help chdbadmin' for help.\n\r");
            } // output(value1[0]+","+value1[1]+","+value2[0]+","+value2[1]+"\n\r"); // diagnostic
            else {
                boolean ok = access.changeAdmin(val_OldAdmin, val_NewAdmin, val_Alias);
                if (ok == true) {
                    output("Admin for " + this.val_Alias + ", have SUCCESSFULLY been CHANGED from " + val_OldAdmin + " to " + val_NewAdmin + ".\n\r");
                } else {
                    output("Admin for " + this.val_Alias + ", have FAILED to be CHANGED from " + val_OldAdmin + " to " + val_NewAdmin + ".\n\r");
                }
            }
            resetAllVals();

        }
        if (args[0].equalsIgnoreCase("deldbadmin")) {
            // output("Not Yet Implemented\n\r");
            String[] value1 = args[1].split("=");
            if (value1[0].equals(this.key_Alias)) {
                this.val_Alias = value1[1];
            }
            if (this.val_Alias == null) {
                output("(!) Wrong syntax. Type 'help deldbadmin' for help.\n\r");
            } // output(value1[0]+","+value1[1]+","+value2[0]+","+value2[1]+"\n\r"); // diagnostic
            else {
                boolean ok = getSql().deleteAllAdmin(val_Alias);
                if (ok == true) {
                    output("DB Profile: " + this.val_Alias + "'s Admin, have SUCCESSFULLY been DELETED.\n\r");
                } else {
                    output("DB Profile: " + this.val_Alias + "'s Admin, have FAILED to be DELETED.\n\r");
                }
            }
            resetAllVals();
        }
        if (args[0].equalsIgnoreCase("listdbadmin")) {
            // output("Not Yet Implemented\n\r");
            int i;
            output("List of Admin\n\r");
            output("=====================\n\r");
            ArrayList aList = getSql().listAdmin();
            Admin admin;
            for (i = 0; i < aList.size(); i++) {
                admin = (Admin) aList.get(i);
                output("Admin: " + admin.getUsername() + ", DB Alias: " + admin.getDbAlias() + "\n\r");
            }
            output("Total Number of Admin: " + i + "\n");
        }
        if (args[0].equalsIgnoreCase("log")) {
            output("Please use your editor to open the '../log/dbdir.log' file.\n\r");
        }
        if (args[0].equalsIgnoreCase("backup")) {
            Backup bk = new Backup(this.server,this.getSql().conn);
            bk.doBackup();
        }
    }

    private void resetAllVals() {
        this.val_Username = null;
        this.val_Password = null;
        this.val_DBPath = null;
        this.val_Alias = null;
        this.val_DBUser = null;
        this.val_DBUser = null;
        this.val_showDbPath = false;
        this.val_showDbUsername = false;
        this.val_showDbPassword = false;
        this.val_showDateTimeReg = false;
        this.val_editDbPath = false;
        this.val_editDbUsername = false;
        this.val_editDbPassword = false;

    }

    private void showMainMenu() {
        output("Main Menu Option");
        output("=========");
        output("1. Manage Users");
        output("2. Manage Database Profiles");
        output("3. Manage ACLs");
        output("4. Manage Settings");
        output("5. View Logs");
        output("6. About");
        output("7. Help");
        output("8. Raw Command");
        output("9. Exit Server");
        output("");
        int option = Integer.parseInt(input.readLine("Option: "));
        handleMainMenuOption(option);
    }

    private void doExitServer() {
        server.doExitServer();
    }

    private void doHelp() {
        output("\n\rHelp\n\r");
        output("====\n\r");
        output("adduser - add new unique user\n\r");
        output("moduser - modify/update user data\n\r");
        output("deluser - delete user\n\r");
        output("showuser - shows information of user\n\r");
        output("listuser - shows a list of all users\n\r");
        output("adddb - add new db profile\n\r");
        output("moddb - modify/update db profile\n\r");
        output("deldb - delete db profile\n\r");
        output("showdb - shows information of db profile\n\r");
        output("listdb - shows a list of all db profile\n\r");
        output("addacl - add new acl profile\n\r");
        output("modacl - modify/update acl profile\n\r");
        output("delacl - delete acl profile\n\r");
        output("showacl - shows information of acl\n\r");
        output("listacl - shows a list of all acl\n\r");
        output("mkdbadmin - creates an admin for a db profile\n\r");
        output("chdbadmin - change admin for a db profile\n\r");
        output("deldbadmin - remove admin for a db profile\n\r");
        output("listdbadmin - shows a list of all db admin and db alias whom they are admin\n\r");
        output("log - show log\n\r");
        output("about - about dbDir\n\r");
        output("backup - backup dbDir\n\r");
        output("\nType 'help <keyword>' or '? <keyword>' for more specific help on a function.\n");
    }

    private void doAbout() {
        output("\ndbDir - v0.1 Stable\n\r");
        output("~~~~~~\n\r");
        output("mode: Server\n\r");
        output("\n\r");
        output("dbDir is a directory system for databases.\n");
    }

    private void doSpecificHelp(String keyword) {
        if (keyword.equals("adduser")) {
            output("adduser username=<username> password=<password>\n\r");
        } else if (keyword.equals("moduser")) {
            output("moduser username=<username> password=<password>\n\r");
        } else if (keyword.equals("deluser")) {
            output("deluser username=<username>\n\r");
        } else if (keyword.equals("showuser")) {
            output("showuser <username>\n\r");
        } else if (keyword.equals("listuser")) {
            output("listuser\n\r");
        } else if (keyword.equals("adddb")) {
            output("adddb dbalias=<db alias> dbusr=<db username> dbpwd=<db password> dbpath=<dbpath>\n\r");
        } else if (keyword.equals("moddb")) {
            output("moddb dbalias=<db alias> dbusr=<db username> dbpwd=<db password> dbpath=<dbpath>\n\r");
        } else if (keyword.equals("deldb")) {
            output("deldb dbalias=<db alias>\n\r");
        } else if (keyword.equals("showdb")) {
            output("showdb <db alias>\n\r");
        } else if (keyword.equals("listdb")) {
            output("listdb\n\r");
        } else if (keyword.equals("addacl")) {
            output("addacl username=<username> dbalias=<db alias> showdbpath=<true/false> showdbusr=<true/false> showdbpwd=<true/false> showdtreg=<true/false> editdbpath=<true/false> editdbusr=<true/false> editdbpwd=<true/false>\n\r");
        } else if (keyword.equals("modacl")) {
            output("modacl username=<username> dbalias=<db alias> showdbpath=<true/false> showdbusr=<true/false> showdbpwd=<true/false> showdtreg=<true/false> editdbpath=<true/false> editdbusr=<true/false> editdbpwd=<true/false>\n\r");
        } else if (keyword.equals("delacl")) {
            output("delacl username=<username> dbalias=<db alias>\n\r");
        } else if (keyword.equals("showacl")) {
            output("showacl username=<username> dbalias=<db alias>\n\r");
        } else if (keyword.equals("listacl")) {
            output("listacl\n\r");
        } else if (keyword.equals("mkdbadmin")) {
            output("mkdbadmin username=<username> dbalias=<db alias>\n\r");
        } else if (keyword.equals("chdbadmin")) {
            output("chdbadmin oldadmin=<old admin username> newadmin=<new admin username> dbalias=<db alias>\n\r");
        } else if (keyword.equals("deldbadmin")) {
            output("deldbadmin dbalias=<db alias>\n\r");
        } else if (keyword.equals("listdbadmin")) {
            output("listdbadmin\n\r");
        } else if (keyword.equals("log")) {
            output("log\n\r");
        } else if (keyword.equals("backup")){
            output("backup\n\r");
        } else {
            output("No such keyword as " + keyword + "\n\r");
        }
    }

    public void output(String message) {
        server.output(message);
    }

    /**
     * @return the sql
     */
    public SQLManager getSql() {
        return sql;
    }

    /**
     * @param sql the sql to set
     */
    public void setSql(SQLManager sql) {
        this.sql = sql;
    }
}
